package org.simple.framework.html.parser.convert;

import org.simple.framework.html.parser.convert.converter.*;

/**
 * 项目名称：simple-framework
 * 类名称：SimpleTypeConverter
 * 类描述：SimpleTypeConverter
 * 创建时间：2018/9/25
 *
 * @author sisyphus   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
public class SimpleTypeConverter implements TypeConverter {

    private TypeChainConverter head;

    public SimpleTypeConverter() {
        head = TypeChainConverter.build(new StringConverter());
        head.next(new BooleanConverter())
                .next(new ByteConverter())
                .next(new CharacterConverter())
                .next(new DoubleConverter())
                .next(new FloatConverter())
                .next(new IntegerConverter())
                .next(new LongConverter())
                .next(new ShortConverter());
    }

    @Override
    public boolean isSupported(Class clazz) {
        return head.isSupported(clazz);
    }

    @Override
    public Object convert(Object o, Class clazz) {
        return head.convert(o, clazz);
    }
}
